package cn.ac.cintcm.dao.hibernate.mysql;

import java.util.List;

import cn.ac.cintcm.dao.hibernate.TherapyDaoGeneric;
import cn.ac.cintcm.model.Therapy;

public class TherapyDaoHibernate extends TherapyDaoGeneric  {

	@SuppressWarnings("unchecked")
	public List<Therapy> getAttentionTherapy() {
		String hsql = "from Therapy where notify=0 and (now() - tdate)/1000000>=(dosage-1)";
	    return  getHibernateTemplate().find(hsql);
	}

	@SuppressWarnings("unchecked")
	public List<Therapy> getRecentTherapy() {
		String hsql = "from Therapy where (now() - tdate)/1000000<=7";
	    return  getHibernateTemplate().find(hsql);
	}

	@SuppressWarnings("unchecked")
	public List<Therapy> getAttentionTherapy(String uid) {
		String hsql = "from Therapy where notify=0 and (now() - tdate)/1000000>=dosage and doctor=?";
	    return  getHibernateTemplate().find(hsql, uid);
	}

	@SuppressWarnings("unchecked")
	public List<Therapy> getRecentTherapy(String uid) {
		String hsql = "from Therapy where (now() - tdate)/1000000<=7 and doctor=?";
	    return  getHibernateTemplate().find(hsql, uid);
	}
}
